#pragma once
#include <iostream>
#include <string>
#include "protocol.h"

using namespace user_protocol;
class calculator
{
public:
    calculator()
    {
    }
    user_protocol::Response Excute(user_protocol::Request req)
    {
        user_protocol::Response res(0, 0);
        //没有输进去
        cout <<"——————————————————————看看下面是不是操作符没有被输进去"<<endl;
        cout << "oper是:"<<req._oper <<endl;
        switch (req._oper)
        {
        case '+':
            res._result = req._x + req._y;
            break;
        case '-':
            res._result = req._x - req._y;
            break;
        case '*':
            res._result = req._x + req._y;
            break;
        case '/':
        {
            if (req._y == 0)
            {
                res._code = 1;
            }
            else
            {
                res._result = req._x / req._y;
            }
        }
        break;
        case '%':
        {
            if (req._y == 0)
            {
                res._code = 2;
            }
            else
            {
                res._result = req._x % req._y;
            }
        }
        break;

        default:
            res._code = 3;
            break;
        }
        return res;
    }
    ~calculator()
    {
    }
};